package mvc.model.inventory

import org.json.JSONObject

class ReplenishGoodsType(
    val name: String, // 商品名称
    val goodsTypeName: String, // 货道名称
    val planNumber: Int
) // 商品数量 , 计划数量
{
    companion object {
        fun withJson(json: JSONObject): ReplenishGoodsType {
            val name = json.getString("goodsName")
            val goodsTypeName = json.getString("cargoData")
            val number = json.getInt("isExist")
            return ReplenishGoodsType(name, goodsTypeName, number)
        }
    }

    var realityNumber = planNumber

    fun toJson(): JSONObject {
        val json = JSONObject()
        json.put("goodsName", name)
        json.put("cargoData", goodsTypeName)
        json.put("isExist", realityNumber)
        return json
    }
}